<?php
require_once 'Vega/Module/Action.php';
require_once 'Vega/Module/AjaxReturn.php';

class Check_UserAction extends Vega_Module_Action
{
	public $_return = null;
	
	public function __construct(Vega_App $app) {
		parent::__construct($app);
		$this->_return = new Vega_Module_AjaxReturn;
	}
		
    public function execute()
    {
		$this->setOption('output', FALSE);
		
		$userId = isset($_REQUEST['user_id'])?$_REQUEST['user_id']:null;
		
		if ($userId != null) {
			$commonDao = Vega_Dao::factory('Bbservice_Common');
			
			$userDetail = $commonDao->getUserDetail($userId);
			
			$this->_return->param = array(
				'user_name' => $userDetail['name'],
				'image_url' => $userDetail['image_url']);
			
		}
		else {
			$this->_return->setError('1', 'Invalid user id');
		}
		
		echo $this->_return->buildOutput();
    }
 
}